<?php
namespace offer\action;

use herosphp\bean\Beans;
use herosphp\core\Controller;
use herosphp\http\HttpRequest;
use herosphp\session\Session;
use herosphp\utils\AjaxResult;

/**
 * @author yu
 */
class OfferAction extends CommonAction {


    public function index(HttpRequest $request) {

        $this->setView("offer_index");

        
    }
    public function add(HttpRequest $request) {

        $this->setView("offer_add");


    }
    public function detail(HttpRequest $request)
    {
        $offer_id = $request->getParameter('offer_id');

        $service = Beans::get('offer.offer.service');

        $service->plusOfferView($offer_id,1);//$service->getRandIncrement());//增加浏览量

        $result['items'] = $service->getOfferProducts($offer_id);

        $result['head'] = $service->getOffer($offer_id);

        if(!$result['head']){

            $jump_url="/mobadmin/offer/add";

            location($jump_url);
        }

        $this->assign('result', $result);

        if(count($result['items'])>2){

            $this->setView("offer_detail");

        }else{

            $this->setView("offer_detail2");
        }

    }

}
